package com.soft.javase.day10.practice;

import java.util.function.Consumer;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/5/4
 */
public class FormatPrint {
    public static void main(String[] args) {
        String[] array = { "张三,女", "李四,女", "王二麻,男" };

        Consumer<String> printName = str -> {
            String name = str.split(",")[0];
            System.out.print("姓名：" + name + "。");
        };

        Consumer<String> printGender = str -> {
            String gender = str.split(",")[1];
            System.out.println("性别：" + gender + "。");
        };

        Consumer<String> printInfo = printName.andThen(printGender);

        for (String info : array) {
            printInfo.accept(info);
        }
    }
}
